##############################################################################
##: 	   Advanced Bonus System
##: 		   Porutchik
##: 	   DarkMod
##: 	        
## :   15 .
##:         
##              / Seed points (  )
##############################################################################

#
#-----[ SQL  ]------------------------------------------
#

ALTER TABLE bb_forums ADD points_disabled TINYINT(1) NOT NULL;
ALTER TABLE bb_users ADD admin_allow_points TINYINT(1) DEFAULT '1' NOT NULL;
INSERT INTO bb_config VALUES ('points_name', ' ');
INSERT INTO bb_config VALUES ('points_post', '1');
INSERT INTO bb_config VALUES ('points_poll', '1');
INSERT INTO bb_config VALUES ('points_donate', '1');
INSERT INTO bb_config VALUES ('points_reply', '5');
INSERT INTO bb_config VALUES ('points_topic', '20');
INSERT INTO bb_config VALUES ('points_vote', '10');
INSERT INTO bb_config VALUES ('points_user_group_auth_ids', '');

#
#-----[  ]------------------------------------------
#
admin/admin_forums.php

#
#-----[  ]------------------------------------------
#
				$prune_days = $row['prune_days'];

#
#-----[   ]------------------------------------------
#
				// Bonus System
				$points_disabled = $row['points_disabled'];
				// Bonus System [END]

#
#-----[  ]------------------------------------------
#
				$prune_days = 0;

#
#-----[   ]------------------------------------------
#
				// Bonus System
				$points_disabled = 0;
				// Bonus System [END]

#
#-----[  ]------------------------------------------
#
			$statuslist .= "<option value=\"" . FORUM_LOCKED . "\" $forumlocked>" . $lang['Status_locked'] . "</option>\n";

#
#-----[   ]------------------------------------------
#
			// Bonus System
			$points_disabled_yes = ( $row['points_disabled'] ) ? 'checked="checked"' : '';
			$points_disabled_no = ( !$row['points_disabled'] ) ? 'checked="checked"' : '';
			$pointslist = '<input type="radio" name="points_disabled" value="1" ' . $points_disabled_yes . '>&nbsp;' . $lang['YES'] . '&nbsp;&nbsp;';
			$pointslist .= '<input type="radio" name="points_disabled" value="0" ' . $points_disabled_no . '>&nbsp;' . $lang['NO'];
            // Bonus System [END]
#
#-----[  ]------------------------------------------
#
				'S_PRUNE_ENABLED' => $prune_enabled,

#
#-----[   ]------------------------------------------
#
				// Bonus System
                'S_POINTS_DISABLED' => $pointslist,
                // Bonus System [END]

#
#-----[  ]------------------------------------------
#
				'L_DAYS' => $lang['Days'],

#
#-----[   ]------------------------------------------
#
				// Bonus System
				'L_POINTS_DISABLED' => sprintf($lang['Points_disabled'], $bb_cfg['points_name']),
                // Bonus System [END]

#
#-----[  () ]------------------------------------------
#
			$prune_days = ($prune_enable) ? intval($_POST['prune_days']) : 0;

#
#-----[   ]------------------------------------------
#
            // Bonus System
            $points_disabled = isset($_POST['points_disabled']) ? intval($_POST['points_disabled']) : 0;
            // Bonus System [END]
#
#-----[  ]------------------------------------------
#
			$columns = ' forum_name,   cat_id,   forum_desc,   forum_order,  forum_status,  prune_days

#
#-----[    ]------------------------------------------
#
,  prune_days

#
#-----[   ]------------------------------------------
#
,  points_disabled

#
#-----[  ]------------------------------------------
#
            $values = "'$forum_name', $cat_id, '$forum_desc', $forum_order, $forum_status, $prune_days
#
#-----[    ]------------------------------------------
#
, $prune_days

#
#-----[   ]------------------------------------------
#
, $points_disabled

#
#-----[  ]------------------------------------------
#
			DB()->query("
				UPDATE ". BB_FORUMS ." SET
					forum_name    = '$forum_name',
					cat_id        = $cat_id,
					forum_desc    = '$forum_desc',
					forum_order   = $forum_order,
					forum_status  = $forum_status,
					prune_days    = $prune_days,

#
#-----[   ]------------------------------------------
#
					points_disabled = $points_disabled,

#
#-----[  ]------------------------------------------
#
modcp.php

#
#-----[  ]------------------------------------------
#
	$sql = "
		SELECT
			f.forum_id, f.forum_name, f.forum_topics

#
#-----[    ]------------------------------------------
#
f.forum_topics

#
#-----[   ]------------------------------------------
#
, f.points_disabled

#
#-----[  ]------------------------------------------
#
	$forum_name = $topic_row['forum_name'];

#
#-----[   ]------------------------------------------
#
	// Bonus System
	$points_disabled = $topic_row['points_disabled'];
	// Bonus System [END]

#
#-----[  ]------------------------------------------
#
	$sql = "SELECT forum_name, forum_topics

#
#-----[    ]------------------------------------------
#
forum_topics

#
#-----[   ]------------------------------------------
#
, points_disabled

#
#-----[  ]------------------------------------------
#
	$forum_name = $topic_row['forum_name'];

#
#-----[  ]------------------------------------------
#
	// Bonus System
	$points_disabled = $topic_row['points_disabled'];
	// Bonus System [END]

#
#-----[  ]------------------------------------------
#
posting.php

#
#-----[  ]------------------------------------------
#
		$select_sql .= (!$submit) ? ', pt.*, u.username, u.user_id

#
#-----[    ]------------------------------------------
#
, u.user_id

#
#-----[   ]------------------------------------------
#
, u.admin_allow_points

#
#-----[  ]------------------------------------------
#
				if ( !DB()->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, "Could not insert user_id for poll", "", __LINE__, __FILE__, $sql);
				}

				$message = $lang['VOTE_CAST'];


#
#-----[   ]------------------------------------------
#
				// Bonus System
				if ($bb_cfg['points_poll'] && !$post_info['points_disabled'] )
				{
					if (($userdata['user_id'] !=ANONYMOUS) && ($userdata['admin_allow_points']))
					{
						add_points($userdata['user_id'], $bb_cfg['points_vote']);
					}
				}
				// Bonus System [END]

#
#-----[  ]------------------------------------------
#
	if (!$error_msg)
	{
		if (!in_array($mode, array('editpost', 'delete', 'poll_delete')))
		{
			$user_id = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['user_id'] : $post_data['poster_id'];

#
#-----[   ]------------------------------------------
#
	if (!$error_msg)
	{
		if (!in_array($mode, array('editpost')))
		{
			$user_id = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['user_id'] : $post_data['poster_id'];
			$post_data['points_disabled'] = $post_info['points_disabled'];
			$post_data['admin_allow_points'] = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['admin_allow_points'] : $post_info['admin_allow_points'];

#
#-----[  ]------------------------------------------
#
viewtopic.php

#
#-----[  ]------------------------------------------
#
$sql = "
	SELECT
	  u.username, u.user_id, u.user_posts,

#
#-----[    ]------------------------------------------
#
u.user_posts

#
#-----[   ]------------------------------------------
#
, u.admin_allow_points, tr.seed_points

#
#-----[  ]------------------------------------------
#
	LEFT JOIN ". BB_POSTS_HTML ." h  ON(h.post_id = p.post_id)

#
#-----[   ]------------------------------------------
#
	LEFT JOIN ". BB_BT_USERS   ." tr ON(tr.user_id = p.poster_id)

#
#-----[  ]------------------------------------------
#
	$user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid'];---------------------------------------------

#
#-----[   ]------------------------------------------
#
	// Bonus System
	if (($userdata['user_id'] != ANONYMOUS) && ($poster_id != ANONYMOUS && BOT_UID))
	{
		$seed_points = ($userdata['user_level'] == ADMIN || user_is_authed($userdata['user_id'])) ? '<span class="txtb" onclick="window.open(\'pointscp.php?' . POST_USERS_URL . '=' . $postrow[$i]['user_id'] . '\', \'points\', \'width=700, height=300, resizable=yes\'); return false;" title="'.sprintf($lang['Points_link_title'], $bb_cfg['points_name']).'">'.$bb_cfg['points_name'].'</span>' : $bb_cfg['points_name'];

		if (!($poster_id == $userdata['user_id']))
		{
			$donate_points = ($postrow[$i]['admin_allow_points']) ? '<span title="'.sprintf($lang['Points_link_title_2'], $bb_cfg['points_name']).'" class="txtb" onclick="window.open(\'pointscp.php?mode=donate&amp;' . POST_USERS_URL . '=' . $postrow[$i]['user_id'] . '\', \'points\', \'width=700, height=400, resizable=yes\'); return false;">'.$postrow[$i]['seed_points'].'</span>' : $lang['Allow_points2'];
		}
		else
		{
			$donate_points = ($postrow[$i]['admin_allow_points']) ? $postrow[$i]['seed_points'] : $lang['Allow_points'];
		}

	}
	else
	{
		$seed_points = '';
		$donate_points = '';
	}
    // Bonus System [END]

#
#-----[  ]------------------------------------------
#
		'IP'      => $ip_btn,

#
#-----[   ]------------------------------------------
#
		// Bonus System
		'L_POINTS'           => $seed_points,
		'POINTS'             => $bb_cfg['points_donate'],
		'DONATE_POINTS'      => $donate_points,
		// Bonus System [END]

#
#-----[  ]------------------------------------------
#
includes/functions_post.php

#
#-----[  ]------------------------------------------
#

$topic_update_sql = '';

#
#-----[   ]------------------------------------------
#

	global $bb_cfg;

#
#-----[  ]------------------------------------------
#
			message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
		}
	}

	if ($mode != 'poll_delete')
	{

#
#-----[   ]------------------------------------------
#
		// Bonus System
		if ( $bb_cfg['points_post'] && !$post_data['points_disabled'] && $post_data['admin_allow_points'] )
		{
			if ( $mode == 'delete' )
			{
				$points = abs( ( $post_data['first_post'] ) ? $bb_cfg['points_topic'] : $bb_cfg['points_reply'] );
				subtract_points($user_id, $points);
			}
			else
			{
				$points = abs( ( $mode == 'newtopic' ) ? $bb_cfg['points_topic'] : $bb_cfg['points_reply'] );
				add_points($user_id, $points);
			}
		}
		// Bonus System [END]

#
#-----[  ]------------------------------------------
#
includes/init_bb.php

#
#-----[  ]------------------------------------------
#
require(INC_DIR .'functions.php');
require(INC_DIR .'sessions.php');
require(INC_DIR .'template.php');
require(INC_DIR .'db/mysql.php');

#
#-----[   ]------------------------------------------
#
require(INC_DIR .'functions_points.php');

#
#-----[  ]------------------------------------------
#
language/lang_russian/lang_admin.php

#
#-----[  ]------------------------------------------
#
// Points System
$lang['Points_updated'] = '    ';
$lang['Click_return_points'] = ' %s%s,      ';
$lang['Points_config_explian'] = '          .';
$lang['Points_sys_settings'] = '  ';
$lang['Points_name'] = ' ';
$lang['Points_name_explain'] = '        (, ...)';
$lang['Points_disabled'] = ' %s';

$lang['Points_enable_post'] = ' %s ';
$lang['Points_enable_donation'] = '   %s';
$lang['Points_enable_browse'] = ' %s  ';
$lang['Points_enable_poll'] = ' %s  ';

$lang['Points_per_reply'] = '  ';
$lang['Points_per_topic'] = '   ';
$lang['Points_per_vote'] = '  ';

$lang['Points_enable_post_explain'] = '   %s     ';
$lang['Points_enable_donation_explain'] = '   %s  ';
$lang['Points_enable_poll_explain'] = '   %s   ';

$lang['Points_per_reply_explain'] = ' %s,  ';
$lang['Points_per_topic_explain'] = ' %s,    ';
$lang['Points_per_vote_explain'] = ' %s,  ';

$lang['Points_user_group_auth'] = ' ';
$lang['Points_user_group_auth_explain'] = ' id ,        ,   id  .';

$lang['Allow_Points'] = '  ?';
$lang['Points_reset'] = '  %s';
$lang['Points_reset_explain'] = '%s     ,   .';

$lang['Points_update_user'] = ' %s ';
$lang['Confirm_points_update'] = ' ,   / %s ?';

$lang['Points_forums'] = '  ';
$lang['Points_forums_explain'] = '     / %s   ';
// Points System [END]

#
#-----[  ]------------------------------------------
#
language/lang_russian/lang_main.php

#
#-----[  ]------------------------------------------
#
// Points System
$lang['Points_link_title_2'] = ' <b>%s</b> ';
$lang['Points_link_title'] = ' <b>%s</b>';
$lang['Points_cp'] = '  ';
$lang['Points_sys'] = '  ';
$lang['Points_donation'] = ' ';
$lang['Points_method'] = '';
$lang['Points_donate'] = '%s%s';
$lang['Points_add_subtract'] = '   %s';
$lang['Points_amount'] = '';
$lang['Points_give_take'] = ' %s   ';
$lang['Points_give'] = ' %s ';
$lang['Add'] = '';
$lang['Subtract'] = '';
$lang['Points_donate_to'] = ',    %s';
$lang['Points_no_username'] = '   .';
$lang['Points_not_admin'] = '     .';
$lang['Points_cant_take'] = '    %s   .';
$lang['Points_thanks_donation'] = '   .';
$lang['Click_return_points_donate'] = ' %s%s,     ';
$lang['Points_cant_donate'] = '      %s  .';
$lang['Points_cant_donate_self'] = '    %s  .';
$lang['Points_user_donation_off'] = '   .';
$lang['Click_return_pointscp'] = ' %s%s,       ';
$lang['Points_user_updated'] = '%s ()  .';
$lang['Points_mass_edit'] = '  ';
$lang['Points_mass_edit_explain'] = '     .';
$lang['Points_mass_edit_explain1'] = '         .';
$lang['Points_notify'] = '     %s';
$lang['Points_notify_explain'] = '  ,   -    %s';
$lang['Points_enter_some_donate'] = '  %s  ';
$lang['Allow_points'] = '<span class="tor-closed-cp" title="  "></span>';
$lang['Allow_points2'] = '<span class="tor-closed-cp" title="  "></span>';
$lang['Guests_cant_points'] = '   %s!';
$lang['Donor_enter_some_donate'] = '    ';

$lang['No_such_user_bot_p'] = ',   %s   xD';
$lang['No_such_user_guest_p'] = ',   %s   o_O';

$lang['Points_subject'] = '   ';
$lang['Total_points'] = '   %s';
$lang['Amount_donate'] = '%s   %s';
// Points System [END]

#
#-----[  ]------------------------------------------
#
templates/admin/admin_forums.tpl

#
#-----[  ]------------------------------------------
#
	<tr>
	  <td class="row1">{L_FORUM_STATUS}</td>
	  <td class="row2"><select name="forumstatus">{S_STATUS_LIST}</select></td>
	</tr>

#
#-----[   ]------------------------------------------
#
	<tr>
	  <td class="row1">{L_POINTS_DISABLED}</td>
	  <td class="row2">{S_POINTS_DISABLED}</td>
	</tr>


#
#-----[  ]------------------------------------------
#
templates/default/viewtopic.tpl

#
#-----[  ]------------------------------------------
#
		<!-- IF postrow.POSTER_FROM --><p class="from"><em>{L_LOCATION}:</em> {postrow.POSTER_FROM}</p><!-- ENDIF -->

#
#-----[   ]------------------------------------------
#
				<!-- IF postrow.POINTS -->{postrow.L_POINTS}&nbsp;{postrow.DONATE_POINTS}<!-- ENDIF -->
#
#-----[    .    ,   ! ]------------------------------------------
#

#
#-----[  ]------------------------------------------
#
includes/sessios.php

#
#-----[  ]------------------------------------------
#
		// Update last visit for logged in users
        if ($login)
        {

#
#-----[   ]------------------------------------------
#
		 if (!get_bt_userdata($this->data['user_id']))
            {
                require(INC_DIR .'functions_torrent.php');
                generate_passkey($this->data['user_id'], true);
            }

#
#-----[  ]------------------------------------------
#
# EoM